import type { AxiosRequestConfig, AxiosResponse } from 'axios'

// 针对AxiosRequestConfig配置进行扩展
export interface InterceptorsType<T = AxiosResponse> {
  requestSuccessFn?: (config: AxiosRequestConfig) => AxiosRequestConfig; // 请求config成功拦截
  requestFailureFn?: (error: any) => any; // 请求config失败拦截

  responseSuccessFn?: (response: T) => T; // 响应成功拦截
  responseFailureFn?: (error: any) => any; // 响应失败拦截
}

// 对AxiosRequestConfig进行扩展
export interface RequestConfig<T = AxiosResponse> extends AxiosRequestConfig {
  baseURL?: string; // 基础地址
  timeout?: number; // 超时时间
  interceptors?: InterceptorsType<T>; // 拦截器
}